<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  <title>LCOV - ged.info - test/utils/algorithm.hpp</title>
  <link rel="stylesheet" type="text/css" href="../../gcov.css">
</head>

<body>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="title">LTP GCOV extension - code coverage report</td></tr>
    <tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>

    <tr>
      <td width="100%">
        <table cellpadding=1 border=0 width="100%">
        <tr>
          <td class="headerItem" width="20%">Current&nbsp;view:</td>
          <td class="headerValue" width="80%" colspan=4><a href="../../index.html">directory</a> - <a href="index.html">test/utils</a> - algorithm.hpp</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Test:</td>
          <td class="headerValue" width="80%" colspan=4>ged.info</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Date:</td>
          <td class="headerValue" width="20%">2009-06-09</td>
          <td width="20%"></td>
          <td class="headerItem" width="20%">Instrumented&nbsp;lines:</td>
          <td class="headerValue" width="20%">6</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Code&nbsp;covered:</td>
          <td class="headerValue" width="20%">0.0 %</td>
          <td width="20%"></td>
          <td class="headerItem" width="20%">Executed&nbsp;lines:</td>
          <td class="headerValue" width="20%">0</td>
        </tr>
        </table>
      </td>
    </tr>
    <tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
  </table>

  <table cellpadding=0 cellspacing=0 border=0>
    <tr>
      <td><br></td>
    </tr>
    <tr>
      <td><pre class="source">
<span class="lineNum">       1 </span>                : //  (C) Copyright Gennadiy Rozental 2004-2008.
<span class="lineNum">       2 </span>                : //  Distributed under the Boost Software License, Version 1.0.
<span class="lineNum">       3 </span>                : //  (See accompanying file LICENSE_1_0.txt or copy at 
<span class="lineNum">       4 </span>                : //  http://www.boost.org/LICENSE_1_0.txt)
<span class="lineNum">       5 </span>                : 
<span class="lineNum">       6 </span>                : //  See http://www.boost.org/libs/test for the library home page.
<span class="lineNum">       7 </span>                : //
<span class="lineNum">       8 </span>                : //  File        : $RCSfile$
<span class="lineNum">       9 </span>                : //
<span class="lineNum">      10 </span>                : //  Version     : $Revision: 49312 $
<span class="lineNum">      11 </span>                : //
<span class="lineNum">      12 </span>                : //  Description : addition to STL algorithms
<span class="lineNum">      13 </span>                : // ***************************************************************************
<span class="lineNum">      14 </span>                : 
<span class="lineNum">      15 </span>                : #ifndef BOOST_ALGORITHM_HPP_062304GER
<span class="lineNum">      16 </span>                : #define BOOST_ALGORITHM_HPP_062304GER
<span class="lineNum">      17 </span>                : 
<span class="lineNum">      18 </span>                : #include &lt;utility&gt;
<span class="lineNum">      19 </span>                : #include &lt;algorithm&gt; // std::find
<span class="lineNum">      20 </span>                : #include &lt;functional&gt; // std::bind1st
<span class="lineNum">      21 </span>                : 
<span class="lineNum">      22 </span>                : #include &lt;boost/test/detail/suppress_warnings.hpp&gt;
<span class="lineNum">      23 </span>                : 
<span class="lineNum">      24 </span>                : //____________________________________________________________________________//
<span class="lineNum">      25 </span>                : 
<span class="lineNum">      26 </span>                : namespace boost {
<span class="lineNum">      27 </span>                : 
<span class="lineNum">      28 </span>                : namespace unit_test {
<span class="lineNum">      29 </span>                : 
<span class="lineNum">      30 </span>                : /// @brief this algorithm search through two collections for first mismatch position that get returned as a pair
<span class="lineNum">      31 </span>                : /// of iterators, first pointing to the mismatch position in first collection, second iterator in second one
<span class="lineNum">      32 </span>                : 
<span class="lineNum">      33 </span>                : /// @param first1 - first collection begin iterator
<span class="lineNum">      34 </span>                : /// @param last1 - first collection end iterator
<span class="lineNum">      35 </span>                : /// @param first2 - second collection begin iterator
<span class="lineNum">      36 </span>                : /// @param last2 - second collection end iterator
<span class="lineNum">      37 </span>                : template &lt;class InputIter1, class InputIter2&gt;
<span class="lineNum">      38 </span>                : inline std::pair&lt;InputIter1, InputIter2&gt;
<span class="lineNum">      39 </span>                : mismatch( InputIter1 first1, InputIter1 last1,
<span class="lineNum">      40 </span>                :           InputIter2 first2, InputIter2 last2 )
<span class="lineNum">      41 </span>                : {
<span class="lineNum">      42 </span>                :     while( first1 != last1 &amp;&amp; first2 != last2 &amp;&amp; *first1 == *first2 ) {
<span class="lineNum">      43 </span>                :         ++first1;
<span class="lineNum">      44 </span>                :         ++first2;
<span class="lineNum">      45 </span>                :     }
<span class="lineNum">      46 </span>                : 
<span class="lineNum">      47 </span>                :     return std::pair&lt;InputIter1, InputIter2&gt;(first1, first2);
<span class="lineNum">      48 </span>                : }
<span class="lineNum">      49 </span>                : 
<span class="lineNum">      50 </span>                : //____________________________________________________________________________//
<span class="lineNum">      51 </span>                : 
<span class="lineNum">      52 </span>                : /// @brief this algorithm search through two collections for first mismatch position that get returned as a pair
<span class="lineNum">      53 </span>                : /// of iterators, first pointing to the mismatch position in first collection, second iterator in second one. This algorithms
<span class="lineNum">      54 </span>                : /// uses supplied predicate for collection elements comparison
<span class="lineNum">      55 </span>                : 
<span class="lineNum">      56 </span>                : /// @param first1 - first collection begin iterator
<span class="lineNum">      57 </span>                : /// @param last1 - first collection end iterator
<span class="lineNum">      58 </span>                : /// @param first2 - second collection begin iterator
<span class="lineNum">      59 </span>                : /// @param last2 - second collection end iterator
<span class="lineNum">      60 </span>                : /// @param pred - predicate to be used for search
<span class="lineNum">      61 </span>                : template &lt;class InputIter1, class InputIter2, class Predicate&gt;
<span class="lineNum">      62 </span>                : inline std::pair&lt;InputIter1, InputIter2&gt;
<span class="lineNum">      63 </span>                : mismatch( InputIter1 first1, InputIter1 last1,
<span class="lineNum">      64 </span>                :           InputIter2 first2, InputIter2 last2,
<span class="lineNum">      65 </span>                :           Predicate pred )
<span class="lineNum">      66 </span>                : {
<span class="lineNum">      67 </span>                :     while( first1 != last1 &amp;&amp; first2 != last2 &amp;&amp; pred( *first1, *first2 ) ) {
<span class="lineNum">      68 </span>                :         ++first1;
<span class="lineNum">      69 </span>                :         ++first2;
<span class="lineNum">      70 </span>                :     }
<span class="lineNum">      71 </span>                : 
<span class="lineNum">      72 </span>                :     return std::pair&lt;InputIter1, InputIter2&gt;(first1, first2);
<span class="lineNum">      73 </span>                : }
<span class="lineNum">      74 </span>                : 
<span class="lineNum">      75 </span>                : //____________________________________________________________________________//
<span class="lineNum">      76 </span>                : 
<span class="lineNum">      77 </span>                : /// @brief this algorithm search through first collection for first element that does not belong a second one
<span class="lineNum">      78 </span>                : 
<span class="lineNum">      79 </span>                : /// @param first1 - first collection begin iterator
<span class="lineNum">      80 </span>                : /// @param last1 - first collection end iterator
<span class="lineNum">      81 </span>                : /// @param first2 - second collection begin iterator
<span class="lineNum">      82 </span>                : /// @param last2 - second collection end iterator
<span class="lineNum">      83 </span>                : template&lt;class ForwardIterator1, class ForwardIterator2&gt;
<span class="lineNum">      84 </span>                : inline ForwardIterator1
<span class="lineNum">      85 </span>                : find_first_not_of( ForwardIterator1 first1, ForwardIterator1 last1, 
<span class="lineNum">      86 </span>                :                    ForwardIterator2 first2, ForwardIterator2 last2 )
<span class="lineNum">      87 </span>                : {
<span class="lineNum">      88 </span>                :     while( first1 != last1 ) {
<span class="lineNum">      89 </span>                :         if( std::find( first2, last2, *first1 ) == last2 )
<span class="lineNum">      90 </span>                :             break;
<span class="lineNum">      91 </span>                :         ++first1;
<span class="lineNum">      92 </span>                :     }
<span class="lineNum">      93 </span>                : 
<span class="lineNum">      94 </span>                :     return first1;
<span class="lineNum">      95 </span>                : }
<span class="lineNum">      96 </span>                : 
<span class="lineNum">      97 </span>                : //____________________________________________________________________________//
<span class="lineNum">      98 </span>                : 
<span class="lineNum">      99 </span>                : /// @brief this algorithm search through first collection for first element that does not satisfy binary 
<span class="lineNum">     100 </span>                : /// predicate in conjunction will any element in second collection
<span class="lineNum">     101 </span>                : 
<span class="lineNum">     102 </span>                : /// @param first1 - first collection begin iterator
<span class="lineNum">     103 </span>                : /// @param last1 - first collection end iterator
<span class="lineNum">     104 </span>                : /// @param first2 - second collection begin iterator
<span class="lineNum">     105 </span>                : /// @param last2 - second collection end iterator
<span class="lineNum">     106 </span>                : /// @param pred - predicate to be used for search
<span class="lineNum">     107 </span>                : template&lt;class ForwardIterator1, class ForwardIterator2, class Predicate&gt;
<span class="lineNum">     108 </span>                : inline ForwardIterator1
<span class="lineNum">     109 </span>                : find_first_not_of( ForwardIterator1 first1, ForwardIterator1 last1, 
<span class="lineNum">     110 </span>                :                    ForwardIterator2 first2, ForwardIterator2 last2, 
<span class="lineNum">     111 </span>                :                    Predicate pred )
<span class="lineNum">     112 </span>                : {
<span class="lineNum">     113 </span>                :     while( first1 != last1 ) {
<span class="lineNum">     114 </span>                :         if( std::find_if( first2, last2, std::bind1st( pred, *first1 ) ) == last2 )
<span class="lineNum">     115 </span>                :             break;
<span class="lineNum">     116 </span>                :         ++first1;
<span class="lineNum">     117 </span>                :     }
<span class="lineNum">     118 </span>                : 
<span class="lineNum">     119 </span>                :     return first1;
<span class="lineNum">     120 </span>                : }
<span class="lineNum">     121 </span>                : 
<span class="lineNum">     122 </span>                : //____________________________________________________________________________//
<span class="lineNum">     123 </span>                : 
<span class="lineNum">     124 </span>                : /// @brief this algorithm search through first collection for last element that belongs to a second one
<span class="lineNum">     125 </span>                : 
<span class="lineNum">     126 </span>                : /// @param first1 - first collection begin iterator
<span class="lineNum">     127 </span>                : /// @param last1 - first collection end iterator
<span class="lineNum">     128 </span>                : /// @param first2 - second collection begin iterator
<span class="lineNum">     129 </span>                : /// @param last2 - second collection end iterator
<span class="lineNum">     130 </span>                : template&lt;class BidirectionalIterator1, class ForwardIterator2&gt;
<span class="lineNum">     131 </span>                : inline BidirectionalIterator1
<span class="lineNum">     132 </span>                : find_last_of( BidirectionalIterator1 first1, BidirectionalIterator1 last1, 
<span class="lineNum">     133 </span><span class="lineNoCov">              0 :               ForwardIterator2 first2, ForwardIterator2 last2 )</span>
<span class="lineNum">     134 </span>                : {
<span class="lineNum">     135 </span><span class="lineNoCov">              0 :     if( first1 == last1 || first2 == last2 )</span>
<span class="lineNum">     136 </span><span class="lineNoCov">              0 :         return last1;</span>
<span class="lineNum">     137 </span>                : 
<span class="lineNum">     138 </span><span class="lineNoCov">              0 :     BidirectionalIterator1 it1 = last1;</span>
<span class="lineNum">     139 </span><span class="lineNoCov">              0 :     while( --it1 != first1 &amp;&amp; std::find( first2, last2, *it1 ) == last2 ) {}</span>
<span class="lineNum">     140 </span>                : 
<span class="lineNum">     141 </span><span class="lineNoCov">              0 :     return it1 == first1 &amp;&amp; std::find( first2, last2, *it1 ) == last2 ? last1 : it1;</span>
<span class="lineNum">     142 </span>                : }
<span class="lineNum">     143 </span>                : 
<span class="lineNum">     144 </span>                : //____________________________________________________________________________//
<span class="lineNum">     145 </span>                : 
<span class="lineNum">     146 </span>                : /// @brief this algorithm search through first collection for last element that satisfy binary 
<span class="lineNum">     147 </span>                : /// predicate in conjunction will at least one element in second collection
<span class="lineNum">     148 </span>                : 
<span class="lineNum">     149 </span>                : /// @param first1 - first collection begin iterator
<span class="lineNum">     150 </span>                : /// @param last1 - first collection end iterator
<span class="lineNum">     151 </span>                : /// @param first2 - second collection begin iterator
<span class="lineNum">     152 </span>                : /// @param last2 - second collection end iterator
<span class="lineNum">     153 </span>                : /// @param pred - predicate to be used for search
<span class="lineNum">     154 </span>                : template&lt;class BidirectionalIterator1, class ForwardIterator2, class Predicate&gt;
<span class="lineNum">     155 </span>                : inline BidirectionalIterator1
<span class="lineNum">     156 </span>                : find_last_of( BidirectionalIterator1 first1, BidirectionalIterator1 last1, 
<span class="lineNum">     157 </span>                :               ForwardIterator2 first2, ForwardIterator2 last2, 
<span class="lineNum">     158 </span>                :               Predicate pred )
<span class="lineNum">     159 </span>                : {
<span class="lineNum">     160 </span>                :     if( first1 == last1 || first2 == last2 )
<span class="lineNum">     161 </span>                :         return last1;
<span class="lineNum">     162 </span>                : 
<span class="lineNum">     163 </span>                :     BidirectionalIterator1 it1 = last1;
<span class="lineNum">     164 </span>                :     while( --it1 != first1 &amp;&amp; std::find_if( first2, last2, std::bind1st( pred, *it1 ) ) == last2 ) {}
<span class="lineNum">     165 </span>                : 
<span class="lineNum">     166 </span>                :     return it1 == first1 &amp;&amp; std::find_if( first2, last2, std::bind1st( pred, *it1 ) ) == last2 ? last1 : it1;
<span class="lineNum">     167 </span>                : }
<span class="lineNum">     168 </span>                : 
<span class="lineNum">     169 </span>                : //____________________________________________________________________________//
<span class="lineNum">     170 </span>                : 
<span class="lineNum">     171 </span>                : /// @brief this algorithm search through first collection for last element that does not belong to a second one
<span class="lineNum">     172 </span>                : 
<span class="lineNum">     173 </span>                : /// @param first1 - first collection begin iterator
<span class="lineNum">     174 </span>                : /// @param last1 - first collection end iterator
<span class="lineNum">     175 </span>                : /// @param first2 - second collection begin iterator
<span class="lineNum">     176 </span>                : /// @param last2 - second collection end iterator
<span class="lineNum">     177 </span>                : template&lt;class BidirectionalIterator1, class ForwardIterator2&gt;
<span class="lineNum">     178 </span>                : inline BidirectionalIterator1
<span class="lineNum">     179 </span>                : find_last_not_of( BidirectionalIterator1 first1, BidirectionalIterator1 last1, 
<span class="lineNum">     180 </span>                :                   ForwardIterator2 first2, ForwardIterator2 last2 )
<span class="lineNum">     181 </span>                : {
<span class="lineNum">     182 </span>                :     if( first1 == last1 || first2 == last2 )
<span class="lineNum">     183 </span>                :         return last1;
<span class="lineNum">     184 </span>                : 
<span class="lineNum">     185 </span>                :     BidirectionalIterator1 it1 = last1;
<span class="lineNum">     186 </span>                :     while( --it1 != first1 &amp;&amp; std::find( first2, last2, *it1 ) != last2 ) {}
<span class="lineNum">     187 </span>                : 
<span class="lineNum">     188 </span>                :     return it1 == first1 &amp;&amp; std::find( first2, last2, *it1 ) != last2 ? last1 : it1;
<span class="lineNum">     189 </span>                : }
<span class="lineNum">     190 </span>                : 
<span class="lineNum">     191 </span>                : //____________________________________________________________________________//
<span class="lineNum">     192 </span>                : 
<span class="lineNum">     193 </span>                : /// @brief this algorithm search through first collection for last element that does not satisfy binary 
<span class="lineNum">     194 </span>                : /// predicate in conjunction will any element in second collection
<span class="lineNum">     195 </span>                : 
<span class="lineNum">     196 </span>                : /// @param first1 - first collection begin iterator
<span class="lineNum">     197 </span>                : /// @param last1 - first collection end iterator
<span class="lineNum">     198 </span>                : /// @param first2 - second collection begin iterator
<span class="lineNum">     199 </span>                : /// @param last2 - second collection end iterator
<span class="lineNum">     200 </span>                : /// @param pred - predicate to be used for search
<span class="lineNum">     201 </span>                : template&lt;class BidirectionalIterator1, class ForwardIterator2, class Predicate&gt;
<span class="lineNum">     202 </span>                : inline BidirectionalIterator1
<span class="lineNum">     203 </span>                : find_last_not_of( BidirectionalIterator1 first1, BidirectionalIterator1 last1, 
<span class="lineNum">     204 </span>                :                   ForwardIterator2 first2, ForwardIterator2 last2, 
<span class="lineNum">     205 </span>                :                   Predicate pred )
<span class="lineNum">     206 </span>                : {
<span class="lineNum">     207 </span>                :     if( first1 == last1 || first2 == last2 )
<span class="lineNum">     208 </span>                :         return last1;
<span class="lineNum">     209 </span>                : 
<span class="lineNum">     210 </span>                :     BidirectionalIterator1 it1 = last1;
<span class="lineNum">     211 </span>                :     while( --it1 != first1 &amp;&amp; std::find_if( first2, last2, std::bind1st( pred, *it1 ) ) != last2 ) {}
<span class="lineNum">     212 </span>                : 
<span class="lineNum">     213 </span>                :     return it1 == first1 &amp;&amp; std::find_if( first2, last2, std::bind1st( pred, *it1 ) ) == last2 ? last1 : it1;
<span class="lineNum">     214 </span>                : }
<span class="lineNum">     215 </span>                : 
<span class="lineNum">     216 </span>                : //____________________________________________________________________________//
<span class="lineNum">     217 </span>                : 
<span class="lineNum">     218 </span>                : } // namespace unit_test
<span class="lineNum">     219 </span>                : 
<span class="lineNum">     220 </span>                : } // namespace boost
<span class="lineNum">     221 </span>                : 
<span class="lineNum">     222 </span>                : //____________________________________________________________________________//
<span class="lineNum">     223 </span>                : 
<span class="lineNum">     224 </span>                : #include &lt;boost/test/detail/enable_warnings.hpp&gt;
<span class="lineNum">     225 </span>                : 
<span class="lineNum">     226 </span>                : #endif // BOOST_ALGORITHM_HPP_062304GER
<span class="lineNum">     227 </span>                : 
<span class="lineNum">     228 </span>                : 
</pre>
      </td>
    </tr>
  </table>
  <br>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
  <tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
  <tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LTP GCOV extension version 1.6</a></td></tr>
  </table>
  <br>

</body>
</html>
